<?php
include 'config.php';
include DIR_FUNCTIONS . 'dt_admin_functions.php';

//classes
include DIR_CLASSES . 'database.class.php';

$dbClass = new Database();
$dbClass->connect();


//random pass
$length = 10;
$characters = '!@#$%&1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$string = '';

$intLength = strlen($characters);

for($i=0;$i<$length;$i++){
    $string .= $characters[mt_rand(1, $intLength)];
}

$username = stripslashes(mysql_real_escape_string($_POST['username']));
$email = stripslashes(mysql_real_escape_string($_POST['email']));
$pass = md5($string);

$query = mysql_query("SELECT * FROM dt_users WHERE username = '$username' AND email = '$email'");
while($row = mysql_fetch_array($query)){
    mail($row['email'], "Detalii administrare DAIMTOUR", "Detalii login: Username: ".$row['username']." / Password: $string / Email: ".$row['email']);
    mysql_query("update dt_users where username = '$username' and email = '$email' set password = '$pass'");
}
header("Location: login.php");
?>